* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --background: #fafafa;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1024px;
    margin: 0 auto;
    padding: 2rem;
}

.header {
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 2rem 0;
    margin-bottom: 3rem;
    backdrop-filter: blur(8px);
}

.header h1 {
    text-align: center;
    color: var(--text-primary);
    font-size: 2.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    margin-bottom: 0.5rem;
}

.subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 1.125rem;
    font-weight: 400;
    margin-top: 0;
}

.form-section,
.query-section {
    background-color: var(--surface);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    margin-bottom: 2rem;
    transition: var(--transition);
}

.form-section:hover,
.query-section:hover {
    box-shadow: var(--shadow-md);
}

.form-section h2,
.query-section h2 {
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    letter-spacing: -0.025em;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
    letter-spacing: 0.025em;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    background-color: var(--surface);
    color: var(--text-primary);
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
    font-family: inherit;
    line-height: 1.5;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    letter-spacing: 0.025em;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-success {
    background-color: #10b981;
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-success:hover:not(:disabled) {
    background-color: #059669;
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--border-light);
    box-shadow: var(--shadow-md);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-info {
    background-color: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-info:hover:not(:disabled) {
    background-color: var(--primary-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-warning {
    background-color: #f59e0b;
    color: white;
    box-shadow: var(--shadow-sm);
}

.button-group {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.button-group .btn {
    flex: 1;
}

.btn-warning:hover:not(:disabled) {
    background-color: #d97706;
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.results-section {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-card {
    background-color: var(--surface);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
    transition: var(--transition);
}

.result-card:hover {
    box-shadow: var(--shadow-md);
}

.result-card h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.025em;
}

.result-content,
.editable-content {
    width: 100%;
    min-height: 200px;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background-color: var(--surface);
    color: var(--text-primary);
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
    resize: vertical;
    transition: var(--transition);
}

.editable-content {
    field-sizing: content;
    min-height: 120px;
    max-height: 400px;
}

.result-content {
    background-color: var(--border-light);
    white-space: pre-wrap;
    max-height: 400px;
    overflow-y: auto;
}

.result-content:focus,
.editable-content:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    background-color: var(--surface);
}

.result-content:hover,
.editable-content:hover {
    border-color: var(--text-muted);
}

.copy-btn,
.generate-full-btn {
    margin-top: 1rem;
    margin-right: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.loading::after {
    content: '';
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 2px solid var(--primary-color);
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
    margin-left: 0.5rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.error,
.success {
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    border-left: 4px solid;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.error {
    background-color: #fef2f2;
    color: #dc2626;
    border-color: #dc2626;
}

.success {
    background-color: #f0fdf4;
    color: #16a34a;
    border-color: #16a34a;
}

.input-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.input-group input {
    flex: 1;
    margin-bottom: 0;
}

.serial-info {
    background-color: var(--border-light);
    padding: 1.5rem;
    border-radius: var(--radius);
    margin-top: 1.5rem;
    border: 1px solid var(--border);
}

.serial-info h4 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
}

.serial-display {
    background-color: #f0fdf4;
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    border: 1px solid #bbf7d0;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.action-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.generate-btn {
    margin-top: 1rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.hidden {
    display: none !important;
}

.admin-login-btn {
    display: none !important;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .form-section,
    .result-card {
        padding: 1.5rem;
    }
    
    .action-buttons {
        flex-direction: column;
        align-items: stretch;
    }
    
    .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .input-group {
        flex-direction: column;
        align-items: stretch;
    }
    
    .input-group .btn {
        width: auto;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--border-light);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* 加载动画 */
.loading-dots::after {
    content: '';
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

/* 成功复制提示 */
.copy-success {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--primary-color);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.3s ease-out;
    z-index: 1000;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* 按钮悬停提示 */
.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

/* 进度条样式 */
.progress-container {
    margin: 1.5rem 0;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-light);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-hover));
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
    animation: progress-animation 2s ease-in-out infinite;
}

@keyframes progress-animation {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

.progress-text {
    margin-top: 0.5rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

/* 自适应功能增强 */
.editable-content,
.result-content {
    min-height: 120px;
    max-height: 400px;
    overflow-y: auto;
    resize: vertical;
    width: 100%;
    box-sizing: border-box;
}

/* 自动调整textarea高度 */
textarea.editable-content {
    field-sizing: content;
    min-height: 120px;
    max-height: 400px;
}

@media (max-width: 768px) {
    .result-card {
        margin: 0.5rem 0;
        padding: 1.25rem;
    }
    
    .editable-content,
    .result-content {
        min-height: 100px;
        max-height: 300px;
        font-size: 0.95rem;
    }
    
    .action-buttons {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .action-buttons .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 0.5rem;
    }
    
    .header {
        padding: 1.5rem 0;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .subtitle {
        font-size: 0.9rem;
    }
    
    .form-section,
    .query-section,
    .results-section {
        padding: 1rem;
        margin: 1rem 0;
    }
    
    .result-card {
        padding: 1rem;
        margin: 0.75rem 0;
    }
    
    .editable-content,
    .result-content {
        min-height: 80px;
        max-height: 250px;
        font-size: 0.9rem;
        padding: 0.75rem;
    }
    
    .form-group label {
        font-size: 0.9rem;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 0.9rem;
        padding: 0.75rem;
    }
    
    .progress-container {
        margin: 1rem 0;
        padding: 0.75rem;
    }
    
    .progress-text {
        font-size: 0.85rem;
    }
}